<?php
	if (count($msg_args) == 1) {
		$return = array();
		foreach($modules as $module => $commands){
		if (count($commands) > 0)
			$return[] = $module . '(' . count($commands) . ')';
		}
		notice('Current modules: ' . implode(', ', $return) . '. To list the commands in a module, use the help <module> command. The number in parathesis is the number of commands in the module.', $source_nick);
	} else if (count($msg_args) == 2) {
		if (array_key_exists($msg_args[1], $modules)) {
			$return = array();
			foreach($modules[$msg_args[1]] as $command => $cmd_level){
				$return[] = "$command($cmd_level)";
			}
			$module_info = 'No details specified.';
			$help = array();
			@include("./help/$msg_args[1].php");
			unset($help);
			if (count($return) == 0) {
				notice("Module $msg_args[1] ($module_info) does not contain any standard commands.", $source_nick);
			} else {
				notice("Commands in module $msg_args[1] ($module_info): " . implode(', ', $return) . '. The number in parathesis in the minimum required level for the command.', $source_nick);
			}
		} else {
			notice("Sorry, the $msg_args[1] module does not exist.", $source_nick);
		}
	} else {
		if (array_key_exists($msg_args[1], $modules)) {
			if (array_key_exists($msg_args[2], $modules[$msg_args[1]])) {
				$help = array();
				@include("./help/$msg_args[1].php");
				if (array_key_exists($msg_args[2], $help)) {
					notice("Module $msg_args[1], command $msg_args[2] (level {$modules[$msg_args[1]][$msg_args[2]]}) - {$help[$msg_args[2]]}", $source_nick);
				} else {
					notice("Module $msg_args[1] does contains a command called $msg_args[2], but the help file does not document it.", $source_nick);
				}
				unset($help);
			} else {
				notice("Module $msg_args[1] does not contain a command called $msg_args[2].", $source_nick);
			}
		} else {
			notice("Sorry, the $msg_args[1] module does not exist.", $source_nick);
		}
	}
?>
